package com.sc.nft.service.impl;

import com.sc.nft.entity.minimall.MallUserWalletDetail;
import com.sc.nft.enums.MallUserWalletDetailTypeEnum;
import com.sc.nft.service.MallUserWalletDetailService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

/**
 * <p>
 * 商城用户钱包明细 服务实现类
 * </p>
 *
 * @author author
 * @since 2024-05-20
 */
@Slf4j
@RequiredArgsConstructor
@Service
public class MallUserWalletDetailServiceImpl implements MallUserWalletDetailService {

    /**
     * 添加钱包明细
     *
     * @param mallUserWalletId
     * @param miniUserId
     * @param type
     * @param amount
     * @param charge
     * @param realAmount
     * @param beforeBalance
     * @param afterBalance
     * @param isAdd
     */
    @Override
    public Long addWalletDetail(Long mallUserWalletId, Long miniUserId, MallUserWalletDetailTypeEnum type, BigDecimal amount, BigDecimal charge, BigDecimal realAmount, BigDecimal beforeBalance, BigDecimal afterBalance, Boolean isAdd) {
        MallUserWalletDetail mallUserWalletDetail = new MallUserWalletDetail();
        mallUserWalletDetail.setMiniUserWalletId(mallUserWalletId);
        mallUserWalletDetail.setMiniUserId(miniUserId);
        mallUserWalletDetail.setType(type);
        mallUserWalletDetail.setAmount(amount);
        mallUserWalletDetail.setCharge(charge);
        mallUserWalletDetail.setRealAmount(realAmount);
        mallUserWalletDetail.setBeforeBalance(beforeBalance);
        mallUserWalletDetail.setAfterBalance(afterBalance);
        mallUserWalletDetail.setIsAdd(isAdd);
        mallUserWalletDetail.insert();
        return mallUserWalletDetail.getId();
    }
}
